package com.itheima.homework04;

import java.util.Scanner;

public class Test04 {
    public static void main(String[] args) {
        //定义一个数组来存储10个学生的成绩
        int[] arr = new int[10];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            //键盘录入10个学生的成绩
            System.out.println("请输入第" + (i + 1) + "位同学的成绩");
            int score = sc.nextInt();
            if (score>=0&&score<=100){
                arr[i] = score;
            }else {
                System.out.println("你输入的数据有误");
                i--;
            }
        }
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            //求和 并输出平均值
            sum += arr[i];
        }
        System.out.println("平均成绩为" + (sum / 10.0));
    }
}
